#!/usr/bin/env node

const rd = require('rd');

const fs = require('fs')

// 同步列出目录下的所有文件
let files = rd.readSync('F:\\dev3\\gaiay-operation\\a1\\resouces\\projects');
for (let f of files) {
    if (fs.statSync(f).isDirectory()) {
        continue;
    }
    let json = JSON.parse(fs.readFileSync(f, 'utf-8'));
    try {
        let html = `

    <h1>${json.projectName}</h1>
    <h2>dev</h2>
    <div class="version" data="http://${json.dev[0].host}:${json.dev[0].port}/s-info?type=version">
        <div property="build-time"></div>    <div property="Env"></div>    <div property="builder"></div>    <div property="git-branch"></div>    <div property="projectName"></div>    <div property="git-commitid"></div>
    </div>
    <hr>
    <div class="tomcat" data="http://${json.dev[0].host}:${json.dev[0].port}/s-info?type=tomcat">
        <div property="name"></div>    <div property="maxThreads"></div>    <div property="currentThreadCount"></div>    <div property="currentThreadsBusy"></div>    <div property="bytesReceived"></div>    <div property="bytesSent"></div>    <div property="requestCount"></div>    <div property="errorCount"></div>    <div property="processingTime"></div>    <div property="maxTime"></div>    <div property="keepAliveCount"></div>    <div property="freeMemory"></div>    <div property="totalMemory"></div>    <div property="usedMemory"></div>    <div property="percentFree"></div>    <div property="hostname"></div>    <div property="ip"></div>
    </div>
    <h2>test</h2>
    <div class="version" data="http://${json.test[0].host}:${json.test[0].port}/s-info?type=version">
        <div property="build-time"></div>    <div property="Env"></div>    <div property="builder"></div>    <div property="git-branch"></div>    <div property="projectName"></div>    <div property="git-commitid"></div>
    </div>
    <hr>
    <div class="tomcat" data="http://${json.test[0].host}:${json.test[0].port}/s-info?type=tomcat">
        <div property="name"></div>    <div property="maxThreads"></div>    <div property="currentThreadCount"></div>    <div property="currentThreadsBusy"></div>    <div property="bytesReceived"></div>    <div property="bytesSent"></div>    <div property="requestCount"></div>    <div property="errorCount"></div>    <div property="processingTime"></div>    <div property="maxTime"></div>    <div property="keepAliveCount"></div>    <div property="freeMemory"></div>    <div property="totalMemory"></div>    <div property="usedMemory"></div>    <div property="percentFree"></div>    <div property="hostname"></div>    <div property="ip"></div>
    </div>

    `;
        console.log(html);
    }catch (e){}

}